@function opposite-direction($directions) {
	$opposite-directions: ();
	$direction-map: (
		"top": "bottom",
		"right": "left",
		"bottom": "top",
		"left": "right",
		"center": "center",
		"ltr": "rtl",
		"rtl": "ltr"
	);

	@each $direction in $directions {
		$direction: to-lower-case($direction);

		@if map-has-key($direction-map, $direction) {
			$opposite-directions: append(
				$opposite-directions,
				unquote(map-get($direction-map, $direction))
			);
		} @else {
			@warn "No opposite direction can be found for `#{$direction}`. Direction omitted.";
		}
	}

	@return $opposite-directions;
}

@mixin triangle($direction, $color: currentcolor, $size: 6px) {
	@if not index(top right bottom left, $direction) {
		@error "方向错误";
	}

	$opposite-directions: opposite-direction("left");

	width: 0;
	height: 0;
	content: "";
	z-index: 2;
	border-#{$opposite-directions}: ($size * 1.5) solid $color;

	$perpendicular-borders: $size solid transparent;

	@if $direction == top or $direction == bottom {
		border-left: $perpendicular-borders;
		border-right: $perpendicular-borders;
	} @else if $direction == right or $direction == left {
		border-bottom: $perpendicular-borders;
		border-top: $perpendicular-borders;
	}
}
